package com.jie.util;

import java.util.ArrayList;
import java.util.List;

/**
 * Excel文件类型
 * @author rwq
 *
 */
public class MyFileFilterExcel extends javax.swing.filechooser.FileFilter {

    private List<String> ext=new ArrayList<String>();

    public MyFileFilterExcel(){
        ext.add(".XLS");
        ext.add(".xls");
        ext.add("xlsx");
        ext.add("XLSX");
    }
    public List<String> getExt() {
        return ext;
    }
    public boolean accept(java.io.File pathname) {
        String fn = pathname.getAbsolutePath().toString();
        if (fn.length() > 4){
            fn = fn.substring(fn.length() - 4, fn.length());
        }
        if (ext.contains(fn) || pathname.isDirectory()){
            return true;
        }
        return false;
    }

    public String getDescription() {
        return "Excel文件(*.xls,*.xlsx)";
    }

}
